package pers.chy.chyappointmentplatform.Config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import pers.chy.chyappointmentplatform.Mapper.HisMapper.Yyjh_XtcsMapper;
import pers.chy.chyappointmentplatform.Model.Yyjh_XtcsDTO;

/**
 * Created by l2h on 18-4-16.
 * Desc: 系统启动完可以做一些业务操作
 */
@Component
@Order(1) //如果有多个runner需要指定一些顺序
public class InitConfig implements ApplicationRunner {

    /**
     * 定义配置值
     */
    public static float g_jwtYxsj=24; // 默认24小时

    @Autowired
    private Yyjh_XtcsMapper yyjh_xtcsMapper;

    /**
     * 此函数在SpringApplication.run()执行完毕后再执行
     * @param args
     * @throws Exception
     */
    @Override
    public void run(ApplicationArguments args) throws Exception {

        // 取JWT有效时间
        Yyjh_XtcsDTO yyjh_xtcsDTO =  yyjh_xtcsMapper.selectByCsmc("JWTYXSJ");
        g_jwtYxsj = Float.parseFloat(yyjh_xtcsDTO.getCsz()) ;

        //
        System.out.println(String.format("初始化配置：JWT有效时间=%s(小时)",g_jwtYxsj) );
    }
}
